﻿Public Partial Class Cancel_popup
    Inherits System.Web.UI.Page

    Dim clsFc As New ClassFunction
    Dim clsGet As New ClassFunctionGetData
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not (IsPostBack) Then
            'Dim lb As Label = CType(Master.FindControl("lbMenu"), Label)
            'lb.Text = "ทำการยกเลิกรายการจอง"
            txtRemark.Text = String.Empty
        End If
    End Sub

    Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If (txtRemark.Text.Trim() = "") Then
            ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " alert('กรุณาทำการระบุสาเหตุการยกเลิกรายการจอง !!');", True)
            Exit Sub
        End If
        Session("Cancel_Description") = txtRemark.Text
        Dim Type As String = Request.QueryString("Type")
        If (Type & "" = "") Then
            'Customer
            ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " parent.closeModal('Z');", True)
        ElseIf (Type & "" = "REJECT") Then
            ' REject เรือบาส
            ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " parent.closeModalReject('V');", True)
        Else

            'VPS MRI Marketing
            Dim Status As String = Session("StatusCancel")
            Session("StatusCancel") = Nothing
            If Status = "VPSMRI" Then
                'VPS MRI
                ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " parent.closeModal('V');", True)
            ElseIf (Status = "MARKETING") Then
                'Marketing
                ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " parent.closeModal('M');", True)
            End If
        End If

    End Sub

    Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Session("StatusCancel") = Nothing
        ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " parent.closeModal('Y');", True)
    End Sub

    Private Sub MainPage_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Dim ds As DataSet = Session("UserData")
        If Not (ds Is Nothing) Then
            Page.MasterPageFile = clsGet.GetMaster_Page(ds.Tables(0).Rows(0).Item("User_Name").ToString(), "")
        End If
    End Sub
End Class